package com.taotao.usermanage.services.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.taotao.usermanage.bean.EasyUIResult;
import com.taotao.usermanage.mapper.UserMapper;
import com.taotao.usermanage.pojo.User;
import com.taotao.usermanage.services.UserService;
import com.taotao.usermanage.util.PageRequest;

@Service
public class UserServicesImpl implements UserService {
    
    @Autowired
    private UserMapper userMapper;

    @Override
    public EasyUIResult queryUserList(PageRequest pageRequest) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("page", pageRequest);
        Long total =  userMapper.getUserCount(map);
        
        List<User> users = userMapper.queryUserList(map);
        return new EasyUIResult(total,users);
    }

    @Override
    public User queryUserById(Long id) {
        User user = userMapper.queryUserById(id);
        return user;
    }

    @Override
    public void saveUser(User user) {
        System.out.println("用户信息为："+user);
        this.userMapper.saveUser(user);
    }

    @Override
    public void updateUser(User user) {
        this.userMapper.updateUser(user);        
    }

    @Override
    public void deleteUserById(Long id) {
        this.userMapper.deleteUserById(id);
    }

}
